package com.gzx.plugin.data.core.sync.record.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gzx.plugin.data.core.sync.record.entity.DataSyncRecord;
import com.gzx.plugin.data.core.sync.record.mapper.DataSyncRecordMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author zjt
 * @description
 * @date 2025/2/13 09:17
 */
@DS("data")
@Service
@RequiredArgsConstructor
public class DataSyncRecordServiceImpl implements DataSyncRecordService {

    private final DataSyncRecordMapper dataSyncRecordMapper;

    /**
     * 根据当前月份和所属公司查询同步记录
     *
     * @param currentMonth
     * @param companyCode
     * @return
     */
    @Override
    public boolean getRecordByCurrentMonthAndCompanyCode(String currentMonth, String companyCode) {
        return dataSyncRecordMapper.selectOne(Wrappers.<DataSyncRecord>lambdaQuery()
                .eq(DataSyncRecord::getCurrentMonth, currentMonth)
                .eq(DataSyncRecord::getCompanyCode, companyCode)) == null;
    }

    /**
     * 增加同步记录
     *
     * @param dataSyncRecord
     */
    @Override
    public void insert(DataSyncRecord dataSyncRecord) {
        dataSyncRecordMapper.insert(dataSyncRecord);
    }
}
